package org.lee.openoffice.controller;

import org.lee.openoffice.service.IConvertService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/")
public class HomeController {

    @Autowired
    private IConvertService convertService;

    @GetMapping("/hello")
    public String hello() {
        return "hello world";
    }

    @GetMapping("preview")
    public void preview(@RequestParam("url") String url, HttpServletResponse response) throws Exception {
        convertService.preview(url, response);
    }
}
